
/**
  ******************************************************************************
  * Copyright 2021 The Microbee Authors. All Rights Reserved.
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  * 
  * http://www.apache.org/licenses/LICENSE-2.0
  * 
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  * 
  * @file       mb_fixed_wing.h
  * @author     baiyang
  * @date       2023-6-29
  ******************************************************************************
  */

#pragma once

#ifdef __cplusplus
extern "C"{
#endif

/*----------------------------------include-----------------------------------*/
#include <stdint.h>
#include <stdbool.h>

#include <parameter/param.h>
/*-----------------------------------macro------------------------------------*/

/*----------------------------------typedef-----------------------------------*/
typedef struct mb_fixed_wing *mb_fixed_wing_t;
typedef const struct mb_fixed_wing *mb_fixed_wing_const_t;

/*
  common parameters for fixed wing aircraft
*/
struct mb_fixed_wing {
    Param_int8 throttle_min;
    Param_int8 throttle_max;
    Param_int8 throttle_slewrate;
    Param_int8 throttle_cruise;
    Param_int8 takeoff_throttle_max;
    Param_int16 airspeed_min;
    Param_int16 airspeed_max;
    Param_int32 airspeed_cruise_cm;
    Param_int32 min_gndspeed_cm;
    Param_int8  crash_detection_enable;
    Param_int16 roll_limit_cd;
    Param_int16 pitch_limit_max_cd;
    Param_int16 pitch_limit_min_cd;
    Param_int8  autotune_level;
    Param_int8  stall_prevention;
    Param_int16 loiter_radius;
    Param_int16 pitch_trim_cd;
    Param_float takeoff_throttle_max_t;
};

struct rangefinder_state {
    bool in_range:1;
    bool have_initial_reading:1;
    bool in_use:1;
    float initial_range;
    float correction;
    float initial_correction;
    float last_stable_correction;
    uint32_t last_correction_time_ms;
    uint8_t in_range_count;
    float height_estimate;
    float last_distance;
};

// stages of flight
enum FlightStage {
    FWFS_TAKEOFF       = 1,
    FWFS_VTOL          = 2,
    FWFS_NORMAL        = 3,
    FWFS_LAND          = 4,
    FWFS_ABORT_LANDING = 7
};

/*----------------------------------variable----------------------------------*/

/*-------------------------------------os-------------------------------------*/

/*----------------------------------function----------------------------------*/

/*------------------------------------test------------------------------------*/

#ifdef __cplusplus
}
#endif



